package io.renren.modules.moyuData.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import io.renren.modules.moyuData.entity.KgmData;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import io.renren.modules.moyuData.entity.KmgDataEntity;
import io.renren.modules.moyuData.service.KmgDataService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 流变数据
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2021-02-02 14:56:39
 */
@RestController
@RequestMapping("/kgmDatabase/kgmSearch")
public class KmgDataController {
    @Autowired
    private KmgDataService kmgDataService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("generator:kmgdata:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = kmgDataService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{kgmId}")
    @RequiresPermissions("generator:kmgdata:info")
    public R info(@PathVariable("kgmId") Long kgmId){
		KmgDataEntity kmgData = kmgDataService.getById(kgmId);

        return R.ok().put("kmgData", kmgData);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("generator:kmgdata:save")
    public R save(@RequestBody KmgDataEntity kmgData){
		kmgDataService.save(kmgData);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("generator:kmgdata:update")
    public R update(@RequestBody KmgDataEntity kmgData){
		kmgDataService.updateById(kmgData);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("generator:kmgdata:delete")
    public R delete(@RequestBody Long[] kgmIds){
		kmgDataService.removeByIds(Arrays.asList(kgmIds));

        return R.ok();
    }

    @RequestMapping("/preparationMethod")
    public R getPreparationMethod(@RequestParam Map<String, Object> params){
        List<KgmData> list=kmgDataService.getPreparationMethod(params);
        return R.ok().put("preparationMethod",list);
    }

}
